package com.itfitness.mchart.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;

import com.blankj.utilcode.util.ToastUtils;
import com.itfitness.mchart.R;
import com.itfitness.mchart.utils.MTextUtil;

import butterknife.BindView;
import butterknife.ButterKnife;

public class NewGroupActivity extends BaseActivity {

    @BindView(R.id.edit_group_name)
    EditText editGroupName;
    @BindView(R.id.edit_group_introduction)
    EditText editGroupIntroduction;
    @BindView(R.id.cb_public)
    CheckBox cbPublic;
    @BindView(R.id.cb_member_inviter)
    CheckBox cbMemberInviter;

    @Override
    protected int LayoutRes() {
        return R.layout.activity_new_group;
    }

    @Override
    protected boolean isHaveTitle() {
        return true;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ButterKnife.bind(this);
        initDatas();
    }

    private void initDatas() {
        setTitle("新建群组", R.color.colorTitleText);
        setRightTitle("保存", R.color.colorTitleText, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                跳转到添加联系人界面
                String groupname = MTextUtil.getText(editGroupName);
                String desc = MTextUtil.getText(editGroupIntroduction);
                if(TextUtils.isEmpty(groupname)){
                    ToastUtils.showShort("请输入群名称");
                    return;
                }
                if(TextUtils.isEmpty(desc)){
                    ToastUtils.showShort("请输入群描述");
                    return;
                }
                Intent startActivityIntent = getStartActivityIntent(GroupChoiceContactActivity.class);
                startActivityIntent.putExtra("groupname",groupname);
                startActivityIntent.putExtra("groupdesc",desc);

                startActivityIntent.putExtra("ispublic",cbPublic.isChecked());
                startActivityIntent.putExtra("isinvite",cbMemberInviter.isChecked());

                startActivity(startActivityIntent);
            }
        });
    }
}
